import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../controller/counter_controller.dart';

class GetViewDemoPage extends GetView<CounterController> {
  const GetViewDemoPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('GetView 状态管理示例'),
        leading: IconButton(
          icon: const Icon(Icons.home),
          onPressed: () => Get.offAllNamed('/'),
        ),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Obx(() => Text('count: ${controller.count}',
                style: const TextStyle(fontSize: 24))),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: controller.increment,
              child: const Text('count+1'),
            ),
          ],
        ),
      ),
    );
  }
}
